package lib.bone.access.module.dict.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.Hibernate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;

/**
 * @Author : kindear
 * @Date : 2021-12-14
 * 维护纵向课题关系词典
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "nepu_topic_dict")
@EntityListeners(AuditingEntityListener.class)
@ApiModel(value = "纵向课题词典")
public class NepuTopicDict {
    @Id
    @GeneratedValue(generator = "jpa-uuid")
    @ApiModelProperty(value = "纵向课题词典ID",name = "id")
    String id;
    /**
     * 词典编码
     */
    @ApiModelProperty("词典编码")
    @Column(name = "code")
    String code;
    /**
     * 纵向类型
     */
    @ApiModelProperty(value = "纵向课题类型",notes = "国家科技重大专项等.")
    @Column(name = "topic_type")
    String topicType;

    /**
     * 纵向级别
     */
    @ApiModelProperty(value = "纵向课题级别",notes = "A/B/C")
    @Column(name = "topic_level")
    String topicLevel;

    /**
     * 纵向课题年工作量
     */
    @ApiModelProperty(value = "工作量Min",notes = "获奖对应的最小工作量")
    @Column(name = "workload_min")
    Integer workloadMin;
    @ApiModelProperty(value = "工作量Max",notes = "获奖对应的最大工作量")
    @Column(name = "workload_max")
    Integer workloadMax;


    @ApiModelProperty(value = "纵向课题词典备注")
    @Column(name = "remark")
    String remark;

    @ApiModelProperty(value = "纵向课题子类")
    @Column(name = "topic_subclasses")
    String topicSubclasses;

    @CreatedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录创建时间",name = "createdTime")
    @Column(name = "created_time")
    private Date createdTime;
    @LastModifiedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录更新时间",name = "updatedTime")
    @Column(name = "updated_time")
    private Date updatedTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        NepuTopicDict nepuTopicDict = (NepuTopicDict) o;
        return id != null && Objects.equals(id, nepuTopicDict.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
